import sys,math
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class Drawing(QWidget):
    def __init__(self,parent=None):
        super(Drawing,self).__init__(parent)
        self.initUI()
    def initUI(self):
        self.setGeometry(300,300,280,270)
        self.setWindowTitle("钢笔样式案例")
        self.show()
    def paintEvent(self,e):
        qp=QPainter()
        qp.begin(self)
        self.drawLines(qp)
        qp.end()
    def drawLines(self,qp):
        brush=QBrush(Qt.SolidPattern)
        qp.setBrush(brush)
        qp.drawRect(10,15,90,60)

        brush = QBrush(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 15, 90, 60)

        brush = QBrush(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 15, 90, 60)

        brush = QBrush(Qt.Dense3Pattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush = QBrush(Qt.HorPattern)  #VerPattern 
        qp.setBrush(brush)
        qp.drawRect(130, 105, 90, 60)

if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=Drawing()
    demo.show()
    sys.exit(app.exec_())